package com.cn.hotel.dao.Impl;

import com.cn.hotel.dao.ICompanyDao;
import com.cn.hotel.model.AboutCompanyModel;
import com.cn.hotel.model.CompanyModel;
import com.cn.hotel.util.GetSqlSession;
import com.cn.hotel.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CompanyImpl implements ICompanyDao {
    /**
     * 根据条件查询符合的所有的信息
     *
     * @param companyModel
     * @return
     */
    @Override
    public List<CompanyModel> findAll(CompanyModel companyModel) {
        return GetSqlSession.getSqlSession().selectList("com.cn.hotel.dao.ICompanyDao.findAll", companyModel);
    }

    /**
     * 获取数据库总数居
     *
     * @param companyModel
     * @return
     */
    @Override
    public int getNumber(CompanyModel companyModel) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.ICompanyDao.getNumber", companyModel);
    }

    @Override
    public CompanyModel findById(Integer temp) {
        return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.ICompanyDao.findById", temp);
    }

    /**
     * 保存修改
     *
     * @param companyModel
     * @return
     */
    @Override
    public int edit(CompanyModel companyModel) {
      return GetSqlSession.getSqlSession().update("com.cn.hotel.dao.ICompanyDao.edit",companyModel);
    }

    /**
     * 添加 新增
     *
     * @param companyModel
     * @return
     */
    @Override
    public int add(CompanyModel companyModel) {
        return GetSqlSession.getSqlSession().insert("com.cn.hotel.dao.ICompanyDao.add",companyModel);
    }

    @Override
    public int delete(Integer temp) {
       return GetSqlSession.getSqlSession().delete("com.cn.hotel.dao.ICompanyDao.delete",temp);
    }
//前端数据调取---------------------------------------------------

    /**
     * 获取关于公司的介绍
     *
     * @return
     */
    @Override
    public AboutCompanyModel getAboutCompanyModel() {
       return GetSqlSession.getSqlSession().selectOne("com.cn.hotel.dao.ICompanyDao.getAboutCompanyModel");
    }
}
